broadway: Clean up broadwayd event sending code
authorAlexander Larsson <alexl@redhat.com>
Tue, 8 Jan 2013 16:08:46 +0000 (17:08 +0100)
committerAlexander Larsson <alexl@redhat.com>
Tue, 8 Jan 2013 17:05:06 +0000 (18:05 +0100)
Use the right size and put the client serial in the right place.

gdk/broadway/broadwayd.c

index ac100be6f4201c39c6f52fada1c4faf852a9a3cf..14f884487cfbe30609e569a88d2b38054614d4fe 100644 (file)
@@ -600,10 +600,12 @@ broadway_events_got_input (BroadwayInputMsg *message,
   guint32 daemon_serial;
 
   size = get_event_size (message->base.type);
+  g_assert (sizeof (BroadwayReplyBase) + size <= sizeof (BroadwayReplyEvent));
 
+  memset (&reply_event, 0, sizeof (BroadwayReplyEvent));
   daemon_serial = message->base.serial;
 
-  reply_event.msg = *message;
+  memcpy (&reply_event.msg, message, size);
 
   for (l = clients; l != NULL; l = l->next)
     {
@@ -612,10 +614,10 @@ broadway_events_got_input (BroadwayInputMsg *message,
       if (client_id == -1 ||
          client->id == client_id)
        {
-         message->base.serial = get_client_serial (client, daemon_serial);
+         reply_event.msg.base.serial = get_client_serial (client, daemon_serial);
 
          send_reply (client, NULL, (BroadwayReply *)&reply_event,
-                     sizeof (BroadwayReplyBase) + size,
+                     G_STRUCT_OFFSET (BroadwayReplyEvent, msg) + size,
                      BROADWAY_REPLY_EVENT);
        }
     }